<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/5/19
  Time: 12:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<% String path = request.getContextPath();%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<script src="<%=path%>/static/js/jquery-3.5.1.min.js"></script>
<style>
    table tr img{
        width: 50px;
        height: 50px;
    }
    table tr{
        text-align: center;
    }
    tr #hot:hover{
        cursor: pointer;
    }
    tr #top:hover{
        cursor: pointer;
    }
</style>
<style>
    #hide{
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
        position: fixed;
        background-image: url("<%=path%>/static/web/css/img/overlay.png");
        opacity: 1;
        z-index: 100;
        display: none;
    }
    #hide #mes{
        margin: 0;
        padding: 0;
        width: 40%;
        height: 45%;
        position: absolute;
        left: 30%;
        top: 15%;
        z-index: 120;
        border: #3a3a3a 8px solid;
        background-color: #cccccc;
        overflow: auto;
    }
    #hide #mes #header{
        margin: 0;
        padding: 0;
        background-color:#019875;
        height: 50px;
        z-index: 150;
        color: white;
    }
    #hide #mes #header #but{
        position: relative;
        background-image: url("<%=path%>/static/web/css/img/controls.png");
        width: 30px;
        height: 30px;
        float: right;
        border:#019875 0px solid;
    }
    #hide #mes #header #but:hover{
        cursor: pointer;
    }
    #hide #mes #header #tit{
        font-size: 25px;

    }
    #hide #mes div {
        text-align: center;
        margin-top: 10px;
        padding: 0;
        height: 50px;
        z-index: 150;
        color: #0C0C0C;
        font-size: 20px;
    }
    #hide #mes #ok{
        margin-top: 40px;
    }
    #hide #mes #ok input:hover{
        cursor: pointer;
        color: #019875;
    }
</style>
<style>
    #hideing{
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
        position: fixed;
        background-image: url("<%=path%>/static/web/css/img/overlay.png");
        opacity: 1;
        z-index: 100;
        display: none;
    }
    #hideing #mesg{
        margin: 0;
        padding: 0;
        width: 40%;
        height: 40%;
        position: absolute;
        left: 30%;
        top: 15%;
        z-index: 120;
        border: #3a3a3a 8px solid;
        background-color: #cccccc;
        overflow: auto;
    }
    #hideing #mesg #headers{
        margin: 0;
        padding: 0;
        background-color:#019875;
        height: 50px;
        z-index: 150;
        color: white;
    }
    #hideing #mesg #headers #butt{
        position: relative;
        background-image: url("<%=path%>/static/web/css/img/controls.png");
        width: 30px;
        height: 30px;
        float: right;
        border:#019875 0px solid;
    }
    #hideing #mesg #headers #butt:hover{
        cursor: pointer;
    }
    #hideing #mesg #headers #sub{
        font-size: 25px;

    }
    #hideing #mesg div {
        text-align: center;
        margin-top: 10px;
        padding: 0;
        height: 50px;
        z-index: 150;
        color: #0C0C0C;
        font-size: 20px;
    }
    #hideing #mesg #oks{
        margin-top: 40px;
    }
    #hideing #mesg #oks input:hover{
        cursor: pointer;
        color: #019875;
    }
</style>
<script>
    $(function () {
        $(".allChoose").click(function () {
            $(":checkbox[id='choose']").prop("checked",$(this).prop("checked"));
        });
    });
    $(function () {
        $("#batchDel").click(function () {
            var idArr = new Array();
            $(":checked[id='choose']").each(function () {
                idArr.push($(this).val());
            });
            $.get("<%=path%>/manage/comment/batchDelReply",{ids:idArr.toString()},function () {
                $(":checked[id='choose']").parent().parent().remove();
            });
        });
    });

    //删除
    $(function () {
        $(".link-del").click(function () {
            var id = $(this).attr("id");
            $.get("<%=path%>/manage/comment/linkDel",{id:id},function () {
                $(this).parent().parent().remove();
            }.bind(this));
        });
        $("tr #hot").click(function () {
            var id = $(this).data("id");
            $.get("<%=path%>/manage/address/updateHot",{id:id},function () {
                if($(this).find("img").length==1)
                {
                    $(this).html("");
                }
                else
                {
                    $(this).html("<img src=\"${pageContext.request.contextPath}/static/manageimages/onCorrect.gif\"/>");
                }
            }.bind(this));

        });
        $("tr #top").click(function () {
            var id = $(this).data("id");

            $.get("<%=path%>/manage/address/updateTop",{id:id},function () {
                if($(this).find("img").length==1)
                {
                    $(this).html("");
                }
                else
                {
                    $(this).html("<img src=\"${pageContext.request.contextPath}/static/manageimages/onCorrect.gif\"/>");
                }
            }.bind(this));
        });
    });
    $(function () {
        $("#but").click(function () {
            $("#hide").css("display","none");
        });
        var id = "";
        $("a[class=link-update]").click(function () {
            id = $(this).attr("id");
            var name = $(this).parent().prev().prev().prev().prev().prev().html();
            $("#hide").css("display","block");
            $("#setUp").val(name);
        });
        $("#button").click(function () {
            var cityName = $("#setUp").val();
            $.get("<%=path%>/manage/address/updataCityName",{id:id,cityName:cityName},function () {
                $("#hide").css("display","none");
                location.reload();
            });
        });
        $("a[class=link-del]").click(function () {
            var id = $(this).attr("id");
            $.get("<%=path%>/manage/address/delCity",{id:id},function () {
                $(this).parent().parent().remove();
            }.bind(this));
        });
    });
</script>
<div id="hide">
    <div id="mes">
        <div id="header">
            <span id="tit">修改</span>
            <button id="but"></button>
        </div>
        <div id="like">
            <span>城市名称:&nbsp;</span>
            <input type="text" id="setUp">
        </div>
        <div id="ok">
            <span style="margin-left: 10px">
                <input type="button" id="button" style="font-size: 20px" value="确定">
            </span>
        </div>
    </div>
</div>
<div id="hideing">
    <div id="mesg">
        <div id="headers">
            <span id="sub">添加链接</span>
            <button id="butt"></button>
        </div>
        <div id="likes">
            <span>省份名称:&nbsp;</span>
            <input type="text" id="addAddress">
        </div>
        <div id="oks">
            <span style="margin-left: 10px">
                <input type="button" id="buttons" style="font-size: 20px" value="确定">
            </span>
        </div>
    </div>
</div>
<jsp:include page="/manage/inc/header"/>
<jsp:include page="/manage/inc/menu"/>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="<%=path%>/manage/index">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="<%=path%>/manage/address/list">地址管理</a><span class="crumb-step">&gt;</span><span>城市管理</span></div>
        </div>
        <div class="result-wrap">
        <div class="result-content">
            <table class="result-tab" width="100%">
                <tr>
                    <th>ID</th>
                    <th>城市</th>
                    <th>邮政编码</th>
                    <th>热门城市</th>
                    <th>推荐城市</th>
                    <th>修改时间</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${requestScope.citys}" var="city">
                    <tr>
                        <td>${city.id}</td>
                        <td>${city.cityName}</td>
                        <td>${city.zipCode}</td>
                        <td id="hot" data-id="${city.id}">
                            <c:if test="${city.hot eq true}"><img src="${pageContext.request.contextPath}/static/manageimages/onCorrect.gif"/></c:if>
                        </td>
                        <td id="top" data-id="${city.id}">
                            <c:if test="${city.top eq true}"><img src="${pageContext.request.contextPath}/static/manageimages/onCorrect.gif"/></c:if>
                        </td>
                        <td>
                            <fmt:formatDate value="${city.dateUpdated}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>
                        </td>
                        <td>
                            <a class="link-update" href="#" id="${city.id}">修改</a>
                            <a class="link-del" href="#" id="${city.id}">删除</a>
                        </td>
                    </tr>
                </c:forEach>
            </table>
        </div>
        </div>
        <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">

    </div>
    <!--/main-->
</div>
<jsp:include page="/manage/inc/footer"/>
